草庐IT

angularjs - Angular ui.router : Update URL without view refresh

全部标签

javascript - AngularJS + NG-Grid 将 row.column.field 传递给 ng-click 事件

如何将{{row.getProperty(col.field)}}传递给ng-click?发生的情况是id没有传回,但网格使用id正确呈现。代码:varapp=angular.module('testing',['ngGrid']);app.config(['$locationProvider',function($locationProvider){$locationProvider.html5Mode(true);}]);app.controller('TestCtrl',function($scope){$scope.details=[];//whateverdummydata$

javascript - 使用 ui.router 渲染页面的 Angular JS 事件

背景场景:我有一个ng-repeat填充我的View,动态放大容器。我需要调整我的的高度当渲染完成时,我还需要在我的应用程序的每个其他页面上执行此操作。我很清楚ready()功能:angular.element(document).ready(function(){console.log('ready')})但是这段代码,放在app.js仅在第一页打开(或重新加载)时执行。重要提示:我正在使用ui.router浏览我的“页面”,所以每当我需要更改页面时,我都会调用“$state.transitionTo()”。问题:是否存在在页面完全呈现时广播的Angular事件?

javascript - 如何获取当前 ui-router 状态的完整 url?

我正在为AngularJS使用ui-router;我正在处理'$stateChangeSuccess'事件,并尝试获取当前状态的完整路径(在“#”之后)。$location.hash()返回空字符串,$state.url仅返回适用于嵌套状态的路径部分。我的完整路径#/a/b$state.url=="/b"$locadtion.hash()==""如何获取#/a/b或/a/b? 最佳答案 您可以随时使用:window.location或:window.location.hash(如果这是你想要的)。

javascript - 当输入字段为空时显示 ng-repeat 列表时 AngularJS 过滤器比较器为真

我将通过这个示例fiddle开始,它演示了使用比较器参数来过滤精确匹配....:http://jsfiddle.net/api/post/library/pure/priority是一个1-100的数字,但我将它作为文本输入并作为字符串过滤所以任何包含子字符串的数据也将通过ng-repeat传递...就像我键入1时它也会显示11、111、132等...这就是我遇到:true比较器的方式。我读过其他建议编写自定义过滤器函数的stackflow答案,但使用真正的比较器,看起来我可以通过以下方式实现我想要的:{{workflowItem.priority}}它只过滤完全匹配的地方。但是,显然

javascript - 将 JavaScript 变量传递给 AngularJs ng-init

我定义了以下javascript变量,需要将memId值传递给AngularJs初始化函数。varmemId="bb7de28f-0f89-4f14-8575-d494203acec7";我收到一个错误:memId未定义。控制台显示ng-init中的memId值未被传入。如何将javascript变量传递给ng-init? 最佳答案 您需要使用$window以“Angular”方式执行此操作:varapp=angular.module('myapp',[]);app.controller('MainCtrl',['$scope','

c# - 在 AngularJS $http 中传递日期到 ASP.NET Web Api

将jsDate对象传递到我的ASP.NETWebApiController时,我总是得到null。我试过传递字符串、字符串数组、时间跨度——所有这些都有效,除了日期。检查请求时,日期是这样传递的:date:"2014-03-13T15:00:00.000Z"Angular:$http({method:'get',url:'api/stuff',params:{date:newDate()});在我的ApiController中:publicIEnumerableGet([FromUri]DateTime?date){...}传递日期的正确方法是什么? 最佳答

javascript - AngularJS:如何在服务中完成 AJAX 调用后执行 Controller 功能?

这是我在服务中的代码。this.loginUser=function(checkUser){Parse.User.logIn(checkUser.username,checkUser.password,{success:function(user){$rootScope.$apply(function(){$rootScope.currentUser=user;});}});};这是我在Controller中的代码:$scope.logIn=function(){authenticationService.loginUser($scope.checkUser);console.log(

javascript - AngularJS 指令在单击时添加类,但如果单击则将其删除并添加到另一个元素

我有一个简单的指令,用于在单击时添加一个类,并在再次单击时将其从元素中删除。但是我想重构它以便在通用菜单中更常见地使用它。相反,如果单击不是当前事件元素的元素,它应该将其从当前元素中删除并将其放置在新元素上。基本上我想向添加一个“事件”类当前事件的元素。在我的菜单中我有:StillGotGameTnTSeldonHitManCommunity.directive('swapit',function(){return{restrict:'A',link:function(scope,elem){varcurrentState=true;elem.on('click',function()

javascript - 使用 $stateProvider 的 AngularJS/Ionic 路由 - Controller 不会在第二次调用状态时重新加载

原始问题我正在使用IonicFramework和AngularJS开发移动应用程序,我遇到了Controller在初始化后无法重新加载的问题。其中一个状态转换(从'app.postbox-details'到'app.audit-questions')应该将参数传递给'app.audit-questions'Controller,但此Controller不会使用新参数更新自身,因为它没有重新加载。代码示例app.js文件-配置angular.module('sf-maintenance',['ionic','starter.controllers','starter.services',

javascript - Angularjs 我可以从另一个 Controller 更改 Controller 的 $scope 值吗?

我有一个HTMLdiv,比如Somehtmldesign在我的Controller中angular.module('core').controller('LoaderController',['$scope','$location','Authentication','$rootScope',function($scope,$location,Authentication,$rootScope){$scope.shouldShow=true;}]);现在,我想从另一个Controller隐藏那个htmldiv,这就是为什么我试图从另一个Controller将$scope.shouldS